package com.lingnan.blog.service;

import com.lingnan.blog.entity.Comment;
import com.lingnan.blog.mapper.CommentMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional(rollbackFor = Exception.class)
public class CommentService {
    @Autowired
    private CommentMapper commentMapper;

    public List<Comment> findAllByAId(Integer aid) {
        return commentMapper.selectAllByAId(aid);
    }

    public Comment findByUIdAndAId(String uid, Integer aid) {
        return commentMapper.selectByUIdAndAId(uid, aid);
    }

    public int save(Comment comment) {
        return commentMapper.insert(comment);
    }
}
